/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vozovypark;

import java.sql.DriverManager;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import junit.framework.TestCase;

/**
 *
 * @author Jozko
 */
public class EmployeeDAOImplTest extends TestCase {
    
    //private static Logger logger = Logger.getLogger(PersistenceUnitTest.class.getName());

    private EntityManagerFactory emFactory;

    private EntityManager em;
    
    public EmployeeDAOImplTest(String testName) {
        super(testName);
    }
    
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        try {
            //logger.info("Starting in-memory database for unit tests");
            System.out.println("foo1");
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            System.out.println("foo2");
            DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close();
        } catch (Exception ex) {
            //ex.printStackTrace();
            fail("Exception during database startup.");
        }
        try {
            //logger.info("Building JPA EntityManager for unit tests");
            emFactory = Persistence.createEntityManagerFactory("testPU");
            em = emFactory.createEntityManager();
        } catch (Exception ex) {
            //ex.printStackTrace();
            fail("Exception during JPA EntityManager instanciation.");
        }
    }
    
    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Test of create method, of class EmployeeDAOImpl.
     */
    public void testCreate() {
        System.out.println("create");
        Employee employee = null;
        EmployeeDAOImpl instance = new EmployeeDAOImpl();
        instance.create(employee);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of get method, of class EmployeeDAOImpl.
     */
    public void testGet() {
        System.out.println("get");
        Long id = null;
        EmployeeDAOImpl instance = new EmployeeDAOImpl();
        Employee expResult = null;
        Employee result = instance.get(id);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of update method, of class EmployeeDAOImpl.
     */
    public void testUpdate() {
        System.out.println("update");
        Employee employee = null;
        EmployeeDAOImpl instance = new EmployeeDAOImpl();
        boolean expResult = false;
        boolean result = instance.update(employee);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of remove method, of class EmployeeDAOImpl.
     */
    public void testRemove() {
        System.out.println("remove");
        Employee employee = null;
        EmployeeDAOImpl instance = new EmployeeDAOImpl();
        instance.remove(employee);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }
}
